#include <iostream>
#include <pthread.h>
#include <cstdio>
pthread_cond_t cond;
pthread_mutex_t lock1;

void* run(void* arg)
{
  char* mes=(char*)arg;
  pthread_detach(pthread_self());
  printf("%s:i am create\n",mes);
  while(1)
  {
    pthread_cond_wait(&cond,&lock1);
    std::cout<<mes<<":"<<"i am recovery"<<std::endl;
  }
}

int main()
{
  pthread_cond_init(&cond,nullptr);
  pthread_mutex_init(&lock1,nullptr);
  pthread_t t1,t2,t3;
  pthread_create(&t1,nullptr,run,(void*)"thread1");
  pthread_create(&t2,nullptr,run,(void*)"thread2");
  pthread_create(&t3,nullptr,run,(void*)"thread3");
  while(1)
  {
    getchar();
    pthread_cond_signal(&cond);
  }
  pthread_cond_destroy(&cond);
  pthread_mutex_destroy(&lock1);
  return 0;
}
